import {createStore, applyMiddleware} from 'redux'

import mainReducers from "./reduces";

import thunk from "redux-thunk";

// 引入我们需要的方法

import {persistStore, persistReducer} from 'redux-persist'

import storage from 'redux-persist/lib/storage'

const persistConfig = {

    key: 'root',

    storage: storage,

}

// persistConfig 对象还可以设置黑名单白名单，就是不需要永久保存的数据。

const myPersistReducer = persistReducer(persistConfig, mainReducers)

const store = createStore(myPersistReducer, applyMiddleware(thunk))

export const persistor = persistStore(store)

export default store